﻿<?xml version="1.0" encoding="utf-8"?>
<AdoNetDataAccess connection="$ArticleDBConnection$" formatter="bizobj of  eComSalesOrder(customer(contact),status,orderContact,paymentMethod)">
	<FormatterInfo paymentMethodTypeField="paymentMethodbizObjTypeName" />
	<Sql>
		SELECT
		so.id, so.createdDate, so.statusId, so.seqNumber, so.lastItemChangeDate, so.discountCode,
		pay.id AS paymentMethodid, pay.bizObjType AS paymentMethodbizObjTypeName,
		Users.id AS customerid, Users.userName AS customeruserName,	Users.companyId as customercompanyId,
		userCon.id AS contactid, userCon.lastName AS contactlastName, userCon.firstName AS contactfirstName,
		Articles.id AS statusid, Articles.baseTitle AS statusbaseTitle, Articles.uniqueTitle AS statusuniqueTitle, Articles.translatedTitles,
		orderCon.id AS orderContactid, orderCon.lastName as orderContactlastName,	orderCon.firstName as orderContactfirstName
		FROM
			eComSalesOrders AS so
			LEFT OUTER JOIN eComPaymentTerms AS pay ON so.paymentTermsId = pay.id
			LEFT OUTER JOIN Users ON so.userId = Users.id
			LEFT OUTER JOIN Contacts AS orderCon ON so.contactId = orderCon.id
			LEFT OUTER JOIN Articles ON so.statusId = Articles.id 
			LEFT OUTER JOIN Contacts As userCon ON Users.id = userCon.id
		WHERE 
			so.id= @id
	</Sql>
	<Param name="id" type="UniqueIdentifier"/>
</AdoNetDataAccess>
